/**
 * @Author ZhangCuirong
 * @Date 2025/9/17 15:51
 * @description:
 */
public class Solution1556 {
    public String thousandSeparator(int n) {
        StringBuilder result = new StringBuilder();
        if (n == 0) {
            return "0";
        }
        int count = 0;
        while (n != 0) {
            int data = n % 10;
            n /= 10;
            count++;
            result.append(data);
            if (count % 3 == 0) {
                result.append(".");
            }
        }
        if (result.charAt(result.length() - 1) == '.') {
            result.deleteCharAt(result.length() - 1);
        }
        return result.reverse().toString();
    }

    public static void main(String[] args) {
        Solution1556 solution = new Solution1556();
        System.out.println(solution.thousandSeparator(123456789));
        System.out.println(solution.thousandSeparator(0));
    }
}
